<?php

use api\User;
use Yaf\Controller_Abstract;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/27
 * Time: 11:43
 */
class ApiController extends Controller_Abstract
{

    /**
     * 用户 CRUD
     */
    public function userAction()
    {
        $api_server = new \Yar_Server(new User());
        $api_server->handle();
        return false;
    }

//    public function cateAction()
//    {
//        $api_server = new \Yar_Server(new Cate());
//        $api_server->handle();
//        return false;
//    }
//
//    public function articleAction()
//    {
//        $api_server = new \Yar_Server(new Article());
//        $api_server->handle();
//        return false;
//    }
//
//    public function msgAction()
//    {
//        $api_server = new \Yar_Server(new Msg());
//        $api_server->handle();
//        return false;
//    }

    public function indexAction()
    {
        //TODO:客户端访问： 当然你也可以写一个单独的类来请求
        try {
            $client = new Yar_client('http://p.com/Api/user');
            echo 'Result:' . $client->add();

        } catch (Exception $e) {
            echo 'Exception:' . $e->getMessage();
        }
        return false;
    }


}